function index_get(){
	//首页公告
			var data1;
			var tbody = "";
			$.ajax({
				type: "GET",
				url: "https://carorder.sicau.edu.cn/adminCar/showNotice",
				dataType: "text", //后台返回格式问题
				data:{
					page:1,
					pageSize:5,	
				},
				success: function(data) {
					
					// console.log(data);
					data1 = eval('(' + data + ')'); 
					if(data1.total%5 == 0){
						sessionStorage.allPage = parseInt(data1.total/5);
					}else{
						sessionStorage.allPage = parseInt(data1.total/5+1);
					}
					if(sessionStorage.user == 1){
						jQuery.each(data1.result,function(i, value) {
							var content = value.content; 
							var trs = '<div class="container things"><h3>' + value.title + `</h3><button onclick=deleteNotice(this) value=${value.id}>删除</button><p><small>发布时间：` + value.time + '</small></p><p>' + content + '</p></div>';
							tbody += trs;
						});
						$("#article").append(tbody);
						$(".pageDiv").createPage({
							pageNum: sessionStorage.allPage,
							current: 1,
							backfun: function(e) {
								//console.log(e);//回调
							}
						});
					}else{
						jQuery.each(data1.result,function(i, value) {
							var content = value.content; 
							var trs = '<div class="container things"><h3>' + value.title + '</h3><p><small>发布时间：' + value.time + '</small></p><p>' + content + '</p></div>';
							tbody += trs;
						});
						$("#article").append(tbody);
						$(".pageDiv").createPage({
							pageNum: sessionStorage.allPage,
							current: 1,
							backfun: function(e) {
								//console.log(e);//回调
							}
						});
					}
				},
				error: function(data) {
					alert("请检查是否连接网络");
					alert(data);
				}
			});
}



function admin_login() {
	var formData = $("#loginForm").serializeJson();
	//var formData.role);
	console.log(formData.role);


	$.ajax({
		type: "POST",
		url: "https://carorder.sicau.edu.cn/adminCar/loginIn",
		// beforeSend: function (xhr) {
        //     xhr.setRequestHeader("token", 1);
		// },
		data:{
			account: formData.username,
			password: formData.password,
		},
		dataType: "text", //后台返回格式问题
		success: function(data) {

			data1 = data1 = eval('(' + data + ')'); 

			if(data1.code == 200 && data1.token != null && data1.campus != null) {
				//得到管理员登陆信息 并存入session中 session中，2代表用户
				sessionStorage.campus=data1.campus;
				sessionStorage.token=data1.token;
				console.log(sessionStorage.token);
				// alert("登录成功");
				sessionStorage.user = 1;

				//跳转至管理员界面
				location.href = "index.html";
			} else {
				alert("账号或密码错误！请重新登陆！");
				sessionStorage.user = 0;
				sessionStorage.campus="";
				window.location.reload();
			}
		},
		error: function(data) {
			alert("登录失败");
		}
	}); 


	//管理员登录 post请求然后跳转页面
} 

function user_login(){
	// location.href = "http://113.54.11.32:8080/CARtest1/user/loginIn";
	// sessionStorage.user = 2;
	// //跳转至用户界面
	// location.href = "../index/index.html";
	$.ajax({
		type: "GET",
		url: "http://113.54.11.32:8080/user/loginIn",
		dataType: "text", //后台返回格式问题
		success: function(data) {
			console.log(data)
			data1 = data1 = eval('(' + data + ')');
			console.log(data1)
			sessionStorage.user = 2;
			sessionStorage.userId = data1.userId
			sessionStorage.userName = data1.userName
				//跳转至用户界面
			location.href = "../index/index.html";
		},
		error: function(data) {
			alert("登录失败");
		}
	}); 
	
}



//退出
function adminExitClick() {
	$.ajax({
		type: "GET",
		url: "https://carorder.sicau.edu.cn/adminCar/loginOut",
		beforeSend: function (xhr) {
			xhr.setRequestHeader("token", sessionStorage.token);
		},
		dataType: "text", //后台返回格式问题
		success: function(data) {
			data1 = data1 = eval('(' + data + ')'); 
			console.log(data1);
			if(data1.code == 200){
				sessionStorage.user = 0;
				sessionStorage.username="";
				sessionStorage.campus="";
				sessionStorage.token="";
				window.location = "../index/index.html";
			}else{
				alert(data1.msg);
			}
		},
		error: function(data) {
			alert("退出失败");
		}
	}); 
	sessionStorage.user = 0;
	sessionStorage.username="";
	sessionStorage.campus="";
	sessionStorage.token="";
	window.location = "../index/home.html";
}

function userExitClick() {
	// $.ajax({
	// 	type: "GET",
	// 	url: "http://113.54.11.32:8080/user/loginOut",
	// 	beforeSend: function (xhr) {
	// 		xhr.setRequestHeader("userId", sessionStorage.userId);
	// 		xhr.setRequestHeader("userName", sessionStorage.userName);
	// 	},
	// 	dataType: "text", //后台返回格式问题
	// 	success: function(data) {
	// 	},
	// 	error: function(data) {
	// 		alert("退出失败");
	// 	}
	// }); 
	
	sessionStorage.user = 0;
	sessionStorage.username="";
	sessionStorage.campus="";
	sessionStorage.token="";
	sessionStorage.userId = "";
	sessionStorage.userName = "";
	location.href = "http://113.54.11.32:8080/user/loginOut"
	// window.location = "../index/index.html";
}

//登录用户与管理员显示
window.onload = function() {
	console.log(sessionStorage.user);
	if(sessionStorage.user == 1) {
		loginWho.innerHTML = '<li class="dropdown"><a href="login.html" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">管理员控制台<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="../admin/addCar.html">临时车辆添加</a></li><li><a href="../admin/dealApplication.html">短期预约处理</a></li><li><a href="../admin/search.html">预约历史记录</a></li><li><a href="../admin/searchControl.html">蓝卡预约记录管理</a></li><li><a href="../admin/getQrCode.html">二维码生成</a></li><li role="separator" class="divider"><li><a href="../admin/admin_article.html">添加公告</a></li><li><a href="javascript:void(0)" onclick="adminExitClick()">退出</a></li></li></ul></li>';
	} else if(sessionStorage.user == 2) {
		loginWho.innerHTML = '<li class="dropdown"><a href="login.html" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">用户控制台<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="../user/userOrder.html">短期车辆预约</a></li><li><a href="../user/userResults.html">申请结果</a></li><li role="separator" class="divider"><li><a href="javascript:void(0)" onclick="userExitClick()">退出</a></li></li></ul></li>';
	} else {
		loginWho.innerHTML = '<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">登录<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="../index/login.html" >管理员登录</a></li><li>';
	}
}


//！！！用户功能！！！

//用户 申请结果回显
function userRes(){
		

			var data3;
			var tbody1 = "";
			$.ajax({
				type: "GET",
				url: "http://113.54.11.32:8080/user/showOrder",
				beforeSend: function (xhr) {
					xhr.setRequestHeader("userId", sessionStorage.userId);
					xhr.setRequestHeader("userName", sessionStorage.userName);
				},
				dataType: "text", //后台返回格式问题
				data:{
					page:1,
					pageSize:10,
				},
				success: function(data) {
					data3 = data.result
					//console.log(data3);
					//data3 = data3.slice(4);console.log(data3); 
					data3 = eval('(' + data3 + ')');
					if (data3 == 0) {						
						tbody1 = "<tr><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td><td>无申请记录</td></tr>";
					}
					else{
						jQuery.each(data3, function(i, value) {
						var trs = "<tr><td>" + value.id + "</td> <td>" + value.name + "</td> <td>" + value.plate_id + "</td> <td>";
						if (value.campus==0) {
							trs = trs + "温江" + "</td> <td>";
						}
						else if (value.campus==1) {
							trs = trs + "雅安" + "</td> <td>";
						}
						else{
							trs = trs + "都江堰" + "</td> <td>";
						}

						//var date3 = new Date(parseInt(value.beginDate) * 1000);
						//Y3 = date3.getFullYear() + '-';
						//M3 = date3.getMonth() + 1 + '-';
						//D3 = date3.getDate() + ' ';
						//date3 = Y3 + M3 + D3;

						//var date4 = new Date(parseInt(value.endDate) * 1000);
						//Y4 = date4.getFullYear() + '-';
						//M4 = date4.getMonth() + 1 + '-';
						//D4 = date4.getDate() + ' ';
						//date4 = Y4 + M4 + D4;
						//最终的时间
						//var res_data = date3 + " 至 " + date4;
						var res_data = value.begin_date + " 至 " + value.end_date;						
 
						trs = trs + res_data + "</td><td>";
						//判断拒绝理由是否为空
						if(!value.refuse){
							trs += "无";
						}
						else{
							trs += value.refuse;
						}
						
						//申请结果判断，2：未处理；1：通过；0：拒绝。
						if(value.status == 2){
							trs +=  "</td>" + "<td><font color='black'>未处理</font></td>";
						}
						else if(value.status == 1){
							trs +=  "</td>" + "<td><font color='green'>通过</font></td>";
						}
						else{
							trs +=  "</td>" + "<td><font color='red'>拒绝</font></td>";
						}

						trs = trs  +  "</tr>"

						tbody1 += trs;
						});
					}


					
					$("#tbody").append(tbody1);
				


				},
				error: function(data) {
					alert("接收失败,code:" + data.status);
				}
			});   		
}


// 序列化表单，将其转化为json格式
$.fn.serializeJson = function() {
	var arr = this.serializeArray();
	var json = {};
	arr.forEach(function(item) {
		var name = item.name;
		var value = item.value;
		if(!json[name]) {
			json[name] = value;
		} else if($.isArray(json[name])) {
			json[name].push(value);
		} else {
			json[name] = [json[name], value];
		}
	});
	return json;
}

//用户预约
function chuan_application() {
	var formData = $("#applicationForm").serializeJson();
	console.log(formData);

	//判断校区
	school = formData.campus;
	if (school == '都江堰校区') {
		school = 2;
	}
	else if (school == '雅安校区') {
		school = 1;
	}
	else{
		school = 0;
	}
	//console.log(school);

	var beginTime_res = formData.beginTime + " 00:00:00";
	var endTime_res = formData.endTime + " 23:59:59" ;
	var carNumber_res = document.getElementById("province").value+document.getElementById("city").value+formData.carNumber;
	//console.log(beginTime_res, endTime_res);

	$.ajax({
		type: "POST",
		url: "http://113.54.11.32:8080/user/Order",
		beforeSend: function (xhr) {
			xhr.setRequestHeader("userId", sessionStorage.userId);
			xhr.setRequestHeader("userName", sessionStorage.userName);
		},
		dataType: "text", //后台返回格式问题
		data:{
			beginDate: beginTime_res,
			endDate: endTime_res,
			plateId: carNumber_res,
			name: formData.userName,
			phone: formData.comeTelephone,
			campus: school,
			reason: formData.reason,
			id:null,
			status:null,
			userId:null,
			updateTime:null,
			createTime:null,
			refuse:null,
		},
		success: function(data) {
			console.log(data)
			alert(data.msg);
		},
		error: function(data) {
			alert(data.msg);
		}
	}); 

}

//！！！管理员功能！！！


//管理员添加临时预约车辆
function adminAdd(){
	var formData = $("#applicationForm").serializeJson();
	console.log(formData);

	var beginTime_res = formData.beginTime + " 00:00:00";
	var endTime_res = formData.endTime + " 23:59:59" ;
	var carNumber_res = document.getElementById("province").value+document.getElementById("city").value+formData.carNumber.toUpperCase();
	console.log(beginTime_res, endTime_res);

	var fd = new FormData();
    fd.append("beginDate", beginTime_res);
    fd.append("endDate", endTime_res);
	fd.append("name", formData.comerName);
	fd.append("phone", formData.comerTelephone);
	fd.append("plateId", carNumber_res);
	if(sessionStorage.campus == 1){
		var datas = {
			"parkNumber": "p200713143536",
			"size": 1,
			"datas": [
				{
					"plate": carNumber_res,
					"chargeType": "不收费",
					"name": formData.comerName,
					"certificate":"无",
					"address": "四川省雅安市",
					"phone": formData.comerTelephone,
					"plateColor": "蓝牌",
					"start": formData.beginTime,
					"end": formData.endTime,
					"dept": "",
					"carType": "错峰",
					"memo": "",
					"areasAndValidity": []
				}
			]
		};
		var resDatas = JSON.stringify(datas);
		console.log(resDatas);


		var settings = {
		"async": true,
		"crossDomain": true,
		"url": "https://carorder.sicau.edu.cn/bcopenapi/out/synWhite",
		"method": "POST",
		"headers": {
		"cache-control": "no-cache",
		"content-type": "application/json",
		"sign": "2a1ac789a5a1bc8b1ab67d7029dc6d72"
		},
		"processData": false,
		"data": resDatas,
		}
	}else if(sessionStorage.campus == 0){
		var datas = {
			"parkNumber": "p200713145437",
			"size": 1,
			"datas": [
				{
					"plate": carNumber_res,
					"chargeType": "不收费",
					"name": formData.comerName,
					"certificate":"无",
					"address": "四川农业大学成都校区",
					"phone": formData.comerTelephone,
					"plateColor": "蓝牌",
					"start": formData.beginTime,
					"end": formData.endTime,
					"dept": "",
					"carType": "错峰",
					"memo": "",
					"areasAndValidity": []
				}
			]
		};
		var resDatas = JSON.stringify(datas);
		console.log(resDatas);


		var settings = {
		"async": true,
		"crossDomain": true,
		"url": "https://carorder.sicau.edu.cn/bcopenapi/out/synWhite",
		"method": "POST",
		"headers": {
		"cache-control": "no-cache",
		"content-type": "application/json",
		"sign": "426d2985aa0dd727dde7e3e0f09babf8"
		},
		"processData": false,
		"data": resDatas,
		}
	}
	$.ajax(settings).done(function (response) {
	console.log(response);
	var jsonData = eval('(' + response + ')');
	if (jsonData["status"] == "success") {
		//发送数据到本地服务器，记录
		$.ajax({
			type: "POST",
			url: "https://carorder.sicau.edu.cn/adminCar/addOrder",
			beforeSend: function (xhr) {
				xhr.setRequestHeader("token", sessionStorage.token);
			},
			processData: false,
			contentType: false,
			// contentType:'application/json;charset=UTF-8',
			// contentType: 'application/x-www-from-urlencoded',
			// data:JSON.stringify(info),
			data:fd,
			dataType: "JSON", //后台返回格式问题
			success: function(data) { 
				if(data.code != 200) {
					alert(data.msg);
				}
				window.location = "../index/index.html";
			},
			error: function(data) {
				alert("申请失败"); 
				window.location = "../index/index.html";
			}
		}); 
	} else if (data["status"] == "fail") {
		alert("预约失败！请检查网络或者重新登陆！");
		window.location.reload();
	}
	}, 'text')
}

//管理员处理车辆预约申请
//同意申请


//时间格式化
Date.prototype.Format = function (fmt) { //author: meizz   
	    var o = {  
	        "M+": this.getMonth() + 1, //月份   
	        "d+": this.getDate(), //日   
	        "H+": this.getHours(), //小时   
	        "m+": this.getMinutes(), //分   
	        "s+": this.getSeconds(), //秒   
	        "q+": Math.floor((this.getMonth() + 3) / 3), //季度   
	        "S": this.getMilliseconds() //毫秒   
	    };  
	    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));  
	    for (var k in o)  
	    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));  
	    return fmt;  
	}; 

function adminYes(id_value) {
	var id_res1 = id_value;
	//alert(Sname+psw);         
	console.log(id_res1);
	$.ajax({
		type: 'GET',
		url: 'https://carorder.sicau.edu.cn/adminCar/getById',
		beforeSend: function (xhr) {
			xhr.setRequestHeader("token", sessionStorage.token);
		},
		data:{
			id: id_res1,
		},
		dataType:  "text",
		success:function(data){
					//是否从本地服务器获取到的该 id 的预约信息
			console.log(data);
			if (data) {
				// 蓝卡云 API 预约车下放
				// 1、请求参数的具体意义，2、厂库编号，3、学校蓝卡云 ip：端口
				var data = eval('(' + data + ')');
				if(data.code != 200) {
					alert(data.msg);
				}
				var bgDate = data.result.beginDate.split(" ")[0];
				var edDate = data.result.endDate.split(" ")[0];
				/*
				//预约下放接口数据
				var datas = {
				"parkNumber": "p200713143536",
						"datas": [{
							"plate": data["plate_id"],
							"start": data["begin_date"],
							"end": data["end_date"],
							"areaId": "0",
							"flag": "1",
							"charge": "0",
							"bookOrderId": id_res1,
							"bookOrderTime": new Date().Format("yyyy-MM-dd HH:mm:ss"),
							"letInEndTime": data["begin_date"],
							"letInStartTime": data["end_date"],
							"memo": ""
					}]
				};
				*/
				//白名单接口数据

				if(sessionStorage.campus == 1){
					var datas = {
						"parkNumber": "p200713143536",
						"size": 1,
						"datas": [
							{
								"plate": data.result.plateId,
								"chargeType": "不收费",
								"name": data.result.name,
								"certificate":"无",
								"address": "四川省雅安市",
								"phone": data.result.phone,
								"plateColor": "蓝牌",
								"start": bgDate,
								"end": edDate,
								"dept": "",
								"carType": "错峰",
								"memo": "",
								"areasAndValidity": []
							}
						]
					};
					var resDatas = JSON.stringify(datas);
					console.log(resDatas);
			
			
					var settings = {
					"async": true,
					"crossDomain": true,
					"url": "https://carorder.sicau.edu.cn/bcopenapi/out/synWhite",
					"method": "POST",
					"headers": {
					"cache-control": "no-cache",
					"content-type": "application/json",
					"sign": "2a1ac789a5a1bc8b1ab67d7029dc6d72"
					},
					"processData": false,
					"data": resDatas,
					}
				}else if(sessionStorage.campus == 0){
					var datas = {
						"parkNumber": "p200713145437",
						"size": 1,
						"datas": [
							{
								"plate": data.result.plateId,
								"chargeType": "不收费",
								"name": data.result.name,
								"certificate":"无",
								"address": "四川农业大学成都校区",
								"phone": data.result.phone,
								"plateColor": "蓝牌",
								"start": bgDate,
								"end": edDate,
								"dept": "",
								"carType": "错峰",
								"memo": "",
								"areasAndValidity": []
							}
						]
					};
					var resDatas = JSON.stringify(datas);
					console.log(resDatas);
			
			
					var settings = {
					"async": true,
					"crossDomain": true,
					"url": "https://carorder.sicau.edu.cn/bcopenapi/out/synWhite",
					"method": "POST",
					"headers": {
					"cache-control": "no-cache",
					"content-type": "application/json",
					"sign": "426d2985aa0dd727dde7e3e0f09babf8"
					},
					"processData": false,
					"data": resDatas,
					}
				}
				$.ajax(settings).done(function (response) {
					console.log(response);
					var jsonData = eval('(' + response + ')');
					if (jsonData["status"] == "success") {
						//发送数据到本地服务器，记录
						$.ajax({
							type: 'POST',
							url: 'https://carorder.sicau.edu.cn/adminCar/agreeOrder',
							beforeSend: function (xhr) {
								xhr.setRequestHeader("token", sessionStorage.token);
							},
							data:{
								id: id_res1,
							},
							dataType:  "text",
							success:function(data){
								var data = eval('(' + data + ')');
								if(data.code != 200) {
									alert(data.msg);
								}
								window.location.reload();
							},
							error:function(data){
								alert("同意失败");
								window.location.reload();
							},
						});
					} else if (data["status"] == "fail") {
						alert("预约失败！请检查网络或者重新登陆！");
						window.location.reload();
					}
				}, 'text')

			} else {
				alert("同意失败");
				window.location.reload();
			}
		},
		error:function(data){
			alert("同意失败");
			window.location.reload();
		},
	});
}


	//拒绝申请

			var admin_reason; //score变量，用来存储用户拒绝理由。
			//添加拒绝理由
			function rec(){
				admin_reason =  prompt("请输入您的拒绝理由(如果无，不输入即可)：");
  			}

			
			//拒绝用户申请
			function adminNo(id_value) {
				var id_res2 = id_value;
				//alert(Sname+psw);
				//console.log(id_res);
				rec();
				if(admin_reason == null){
					alert("已取消拒绝");
					window.location.reload();
					return 0;
				}

				$.ajax({
					type: 'POST',
					url: 'https://carorder.sicau.edu.cn/adminCar/refuseOrder',
					beforeSend: function (xhr) {
						xhr.setRequestHeader("token", sessionStorage.token);
					},
					data:{
						id: id_res2,
						refuse: admin_reason
					},
					dataType:  "text",
					success:function(data){
						var data = eval('(' + data + ')');
						if(data.code != 200) {
							alert(data.msg);
						}
						window.location.reload();
					},
					error:function(data){
						alert("拒绝失败");
						window.location.reload();
					},
				});
			}

			function getAllApplication(){
				//管理员申请管理
				var data3;
				var tbody1 = "";
				$.ajax({
					type: "GET",
					url: "https://carorder.sicau.edu.cn/adminCar/showPendingOrder",
					beforeSend: function (xhr) {
						xhr.setRequestHeader("token", sessionStorage.token);
					},
					dataType: "text", //后台返回格式问题
					data:{
						page:1,
						pageSize:10,	
					},
					success: function(data) {
						// data3 = data
						//console.log(data3);
						// data3 = data3.slice(4);
						data3 = eval('(' + data + ')'); 
						if(data3.total%10 == 0){
							sessionStorage.allPage = parseInt(data3.total/10);
						}else{
							sessionStorage.allPage = parseInt(data3.total/10+1);
						}
						jQuery.each(data3.result, function(i, value) {
							var trs = "<tr><td hidden>" + value.id + "</td> <td>" +value.name+"</td><td>"+ value.plateId + "</td> <td>" + value.phone + "</td><td>";
							
							var res_data = value.beginDate + " 至 " + value.endDate;
							
							
							//同意或拒绝两种操作方法
							trs +=  res_data + "</td><td>"+ value.reason +"<td><a href='javascript:adminYes(" + value.id + ")' class='btn btn-primary btn-xs'>同意</a><a href='javascript:adminNo(" + value.id + ")' class='btn btn-danger btn-xs'>拒绝</a></td>" + "</tr>";

							tbody1 += trs;
						});
						$("#tbody").append(tbody1);
						$(".pageDiv").createPage({
							pageNum: sessionStorage.allPage,
							current: 1,
							backfun: function(e) {
								//console.log(e);//回调
							}
						});
					},
					error: function(data) {
						alert("接收失败,code:" + data.status);
					}
				});
			}


			
//搜索预约车辆
function getAllHistory(){
	//显示所有历史记录
			var data3;
			var tbody1 = "";
			$.ajax({
				type: "GET",
				url: "https://carorder.sicau.edu.cn/adminCar/showOrderHistory",
				beforeSend: function (xhr) {
					xhr.setRequestHeader("token", sessionStorage.token);
				},
				dataType: "text", //后台返回格式问题
				data:{
					page:1,
					pageSize:10,	
				},
				success: function(data) {
					data3 = data
					//console.log(data3);
					//data3 = data3.slice(4);console.log(data3); 
					data3 = eval('(' + data3 + ')');
					if(data3.total%10 == 0){
						sessionStorage.allPage = parseInt(data3.total/10);
					}else{
						sessionStorage.allPage = parseInt(data3.total/10+1);
					}

					jQuery.each(data3, function(i, value) {
						var trs = "<tr><td hidden>" + value.id + "</td> <td>" +value.plateId+"</td><td>"+ value.name + "</td> <td>" + value.phone + "</td><td>";

						var res_data = value.beginDate + " 至 " + value.endDate;
						
						trs +=  res_data + "</td><td>"+ value.reason;

						//申请结果判断，2：未处理；1：通过；0：拒绝。
						if(value.status == 2){
							trs +=  "</td>" + "<td><font color='black'>未处理</font></td>";
						}
						else if(value.status == 1){
							trs +=  "</td>" + "<td><font color='green'>通过</font></td>";
						}
						else{
							trs +=  "</td>" + "<td><font color='red'>拒绝</font></td>";
						}

						trs = trs  +  "</tr>"

						tbody1 += trs;
					});
					$("#searchResult").append(tbody1);
				},
				error: function(data) {
					alert("接收失败,code:" + data.status);
				}
			});
}


//搜索目标车辆
		function searchCar(){
			var formData = $("#searchText").serializeJson();
			//console.log(formData.carNumber);
			$("#tbody").empty();
			$("#pageDiv").empty();
			var tbody1 = ""
			$.ajax({
				type: "GET",
				url: "https://carorder.sicau.edu.cn/adminCar/queryByLicensePlate",
				beforeSend: function (xhr) {
					xhr.setRequestHeader("campus",sessionStorage.campus);
					xhr.setRequestHeader("token", sessionStorage.token);
				},
				data:{
					licensePlate: formData.carNumber,
				},
				dataType: "text", //后台返回格式问题
				success: function(data) {
					// $("#searchResult>tbody").html('');
					// jQuery删除table除第一行以外的所有行
					// $("#searchResult tbody tr").eq(0).nextAll().remove();
					data3 = eval('(' + data + ')');
					// data3 = data.result
					console.log(data);
					console.log(data3);
					//data3 = data3.slice(4);console.log(data3); 
					if (data3.msg != "OK" ) {
						alert("无该辆车记录");
						// tbody1 = "<tr><td>无该辆车记录</td><td>无该辆车记录</td><td>无该辆车记录</td><td>无该辆车记录</td><td>无该辆车记录</td><td>无该辆车记录</td><td>无该辆车记录</td></tr>";
					}
					
					else{
						console.log(data3);	
						
						var trs = "<tr><td hidden>" + data3.result.id + "</td> <td>" +data3.result.plateId+"</td><td>"+ data3.result.name + "</td> <td>" + data3.result.phone + "</td><td>";

						var res_data = data3.result.beginDate + " 至 " + data3.result.endDate;
						
						trs +=  res_data + "</td><td>"+ data3.result.reason;

						//申请结果判断，2：未处理；1：通过；0：拒绝。
						if(data3.result.status == 2){
								trs +=  "</td>" + "<td><font color='black'>未处理</font></td>";
						}
						else if(data3.result.status == 1){
								trs +=  "</td>" + "<td><font color='green'>通过</font></td>";
						}
						else{
								trs +=  "</td>" + "<td><font color='red'>拒绝</font></td>";
						}

						trs = trs  +  "</tr>"

						tbody1 += trs;
							
						;
					}
					$("#searchResult tr:gt(0)").remove();
					$("#searchResult").append(tbody1);
				},
				error: function(data) {
					// alert("请检查是否连接网络");
					alert(data);
				}
			});
		}
		function searchWhiteCar(){
			var formData = $("#searchText").serializeJson();
			//console.log(formData.carNumber);
			$("#tbody").empty();
			$("#pageDiv").empty();
			var tbody1 = ""
			$.ajax({
				type: "GET",
				url: "https://carorder.sicau.edu.cn/adminCar/queryWhite",
				beforeSend: function (xhr) {
					xhr.setRequestHeader("campus",sessionStorage.campus);
					xhr.setRequestHeader("token", sessionStorage.token);
				},
				data:{
					PlateNumb: formData.carNumber,
				},
				dataType: "text", //后台返回格式问题
				success: function(data) {
					// $("#searchResult>tbody").html('');
					// jQuery删除table除第一行以外的所有行
					// $("#searchResult tbody tr").eq(0).nextAll().remove();
					data3 = eval('(' + data + ')');
					// data3 = data.result
					console.log(data);
					console.log(data3);
					//data3 = data3.slice(4);console.log(data3); 
					if (data3.msg == "[]" ) {
						alert("无该辆车记录");
						// tbody1 = "<tr><td>无该辆车记录</td><td>无该辆车记录</td><td>无该辆车记录</td><td>无该辆车记录</td><td>无该辆车记录</td><td>无该辆车记录</td><td>无该辆车记录</td></tr>";
					}else{
						var sum = data3.msg.split(",");
						// console.log(data3);	
						
						var trs = "<tr><td>" + sum[5].split("=")[1] + "</td> <td>"; 

						var res_data = sum[6].split("=")[1] + " 至 " + sum[0].split("=")[1];
						
						trs +=  res_data + "</td><td>"+ sum[3].split("=")[1] + "</td><td>" + sum[4].split("=")[1] + "</td><td>";

						//申请结果判断，2：未处理；1：通过；0：拒绝。
						// if(data3.msg.status == 2){
						// 		trs +=  "</td>" + "<td><font color='black'>未处理</font></td>";
						// }
						// else if(data3.msg.status == 1){
						// 		trs +=  "</td>" + "<td><font color='green'>通过</font></td>";
						// }
						// else{
						// 		trs +=  "</td>" + "<td><font color='red'>拒绝</font></td>";
						// }
						var deletePlate = "";
						deletePlate += '"';
						deletePlate += sum[5].split("=")[1];
						deletePlate += '"';
						trs += "<a href='javascript:adminWhiteDelete(" + deletePlate + ")' class='btn btn-primary btn-xs'>删除</a></td>"

						trs = trs  +  "</tr>"

						tbody1 += trs;
							
						;
					}
					$("#searchResult tr:gt(0)").remove();
					$("#searchResult").append(tbody1);
				},
				error: function(data) {
					alert("请检查是否连接网络");
					// alert(data);
				}
			});
		}
		//删除蓝卡预约记录
		function adminWhiteDelete(id_value){
			var id_res2 = id_value;
			$.ajax({
				type: "GET",
				url: "https://carorder.sicau.edu.cn/adminCar/deleteWhite",
				beforeSend: function (xhr) {
					xhr.setRequestHeader("campus",sessionStorage.campus);
					xhr.setRequestHeader("token", sessionStorage.token);
				},
				dataType: "text", //后台返回格式问题
				data:{
					PlateNumb:id_res2,
				},
				success: function(data) {
					alert("删除成功");
					window.location = "../admin/searchControl.html";
				},
				error: function(data) {
					alert("删除失败");
					window.location = "../admin/searchControl.html";
				}
			}); 
		}
		//显示所有历史记录
		function searchAll(){
			window.location.href="../admin/search.html";
		}

//生成二维码图片
function getQrcode() {
	

	var formData = $("#applicationForm").serializeJson();
	//var enUrl = encodeURI("http://113.54.11.32/CARtest/admin/qrCodeApplication.html" + "?unit="+ formData["comerName"] + "&beginDate=" + formData["beginTime"] +" 00:00:00&endDate=" + formData["endTime"] + " 23:59:59&reason=" + formData["reason"]);
	//var res = "http://113.54.11.32/CARtest/admin/qrCodeApplication.html" + "?beginDate=" + formData["beginTime"] +" 00:00:00&endDate=" + formData["endTime"] + " 23:59:59&campus=" + sessionStorage.campus;	
	var res = "https://carorder.sicau.edu.cn/SICAU/adminCar/admin/qrCodeApplication.html" + "?beginDate=" + formData["beginTime"] +"&endDate=" + formData["endTime"] + "&campus=" + sessionStorage.campus;

	console.log(res);

	var qrcode = $('#qrcode').qrcode({
			width: 128,
			height: 128,
			text: res,
		});

}

//重置二维码生成页面
function refresh(){
	window.location.reload();
}


//判断二维码是否过期
function qr_BeOverdue(){
	//获取url上的二维码截止日期
	var reg = new RegExp("(^|&)"+ "endDate" +"=([^&]*)(&|$)"); 
	var r = window.location.search.substr(1).match(reg); 
	var end_Time = Date.parse(r[2].slice(0,10));

	//获取今天的时间
	var time = new Date();
	var m = time.getMonth() + 1;
	var t = time.getFullYear() + "-" + m + "-" + (time.getDate()-1);
	var today_Time = Date.parse(t)

	if(end_Time < today_Time){
		alert("对不起，该二维码已失效！");
		window.location.href="../index/index.html";
	}


}


//二维码用户预约数据传输
function qr_application(){
	var formData = $("#applicationForm").serializeJson();
	console.log(formData);
	var test = location.href;
	console.log(test);
	var searchText = test.replace("?","?&").split("&");
	console.log(searchText);
	var bgDate = searchText[1].split("=")[1];
	var edDate = searchText[2].split("=")[1];
	var ad = searchText[3].split("=")[1];
	
	// var reg = new RegExp("(^|&)"+ "reason" +"=([^&]*)(&|$)"); 
	// var r = window.location.search.substr(1).match(reg); 
	// var res = r[2];
	var qrData = {
		plateId: document.getElementById("qcProvince").value+document.getElementById("qcCity").value+formData["carNumber"].toUpperCase(),
		name: formData["userName"],
		phone: formData["comTelephone"],
		beginDate:bgDate+" 00:00:00",
		endDate:edDate+" 23:59:59",
		campus:ad,
		reason:null,
		id:null,
		status:null,
		userId:null,
		updateTime:null,
		createTime:null,
		refuse:null,
	}

	if(ad == 1){
		var datas = {
			"parkNumber": "p200713143536",
			"size": 1,
			"datas": [
				{
					"plate": qrData["plateId"],
					"chargeType": "不收费",
					"name": qrData["name"],
					"certificate":"无",
					"address": "四川省雅安市",
					"phone": qrData["phone"],
					"plateColor": "蓝牌",
					"start": bgDate,
					"end": edDate,
					"dept": "",
					"carType": "错峰",
					"memo": "",
					"areasAndValidity": []
				}
			]
		};
		var resDatas = JSON.stringify(datas);
		console.log(resDatas);


		var settings = {
		"async": true,
		"crossDomain": true,
		"url": "https://carorder.sicau.edu.cn/bcopenapi/out/synWhite",
		"method": "POST",
		"headers": {
		"cache-control": "no-cache",
		"content-type": "application/json",
		"sign": "2a1ac789a5a1bc8b1ab67d7029dc6d72"
		},
		"processData": false,
		"data": resDatas,
		}
	}else if(ad == 0){
		var datas = {
			"parkNumber": "p200713145437",
			"size": 1,
			"datas": [
				{
					"plate": qrData["plateId"],
					"chargeType": "不收费",
					"name": qrData["name"],
					"certificate":"无",
					"address": "四川农业大学成都校区",
					"phone": qrData["phone"],
					"plateColor": "蓝牌",
					"start": bgDate,
					"end": edDate,
					"dept": "",
					"carType": "错峰",
					"memo": "",
					"areasAndValidity": []
				}
			]
		};
		var resDatas = JSON.stringify(datas);
		console.log(resDatas);


		var settings = {
		"async": true,
		"crossDomain": true,
		"url": "https://carorder.sicau.edu.cn/bcopenapi/out/synWhite",
		"method": "POST",
		"headers": {
		"cache-control": "no-cache",
		"content-type": "application/json",
		"sign": "426d2985aa0dd727dde7e3e0f09babf8"
		},
		"processData": false,
		"data": resDatas,
		}
	}

	$.ajax(settings).done(function (response) {
	console.log(response);
	var jsonData = eval('(' + response + ')');
	if (jsonData["status"] == "success") {
		//发送数据到本地服务器，记录
		$.ajax({
			type: 'POST',
			// url: 'http://113.54.11.32:8080/user/orderByCode'+searchText,
			url: 'https://carorder.sicau.edu.cn/adminCar/orderByCode',
			data:JSON.stringify(qrData),
			contentType:'application/json',
			dataType:'text',
			success: function(data) {
				var data3 = eval('(' + data + ')');
				console.log(data3)
				if(data.code == 200) {
					window.location.href="qrCodeSuccess.html";
				} else{
					alert(data3.msg);
				}
				
			},
			error: function(data) {
				alert("网络问题，请重新扫描二维码！");
				window.location.href="qrCodeFailed.html";
			}
		});
	} else if (data["status"] == "fail") {
		alert("预约失败！请检查网络或者重新登陆！");
		window.location.reload();
	}
	}, 'text')
}

//下载二维码图片
//判断浏览器类型
function myBrowser() {
	var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
	var isOpera = userAgent.indexOf("Opera") > -1;
	if(isOpera) {
		return "Opera"
	}; //判断是否Opera浏览器
	if(userAgent.indexOf("Firefox") > -1) {
		return "FF";
	} //判断是否Firefox浏览器
	if(userAgent.indexOf("Chrome") > -1) {
		return "Chrome";
	}
	if(userAgent.indexOf("Safari") > -1) {
		return "Safari";
	} //判断是否Safari浏览器
	if(userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
		return "IE";
	}; //判断是否IE浏览器
	if(userAgent.indexOf("Trident") > -1) {
		return "Edge";
	} //判断是否Edge浏览器
};

function downloadQrcode() {
	var canvas = $('#qrcode').find("canvas").get(0); //取到canvas

	var url = canvas.toDataURL('image/jpeg'); //把canvas转换成base64

	myBrowser(); //判断浏览器类型

	if(myBrowser() === "IE" || myBrowser() === "Edge") {   
		var blob = canvas.msToBlob();
		window.navigator.msSaveBlob(blob, a + '.png');
	} else {
		$('#download').attr({
			href: url,
			download: name
		}).get(0).click();
	}
}
